<?php


class Html extends ExportConverter {

	private static function escape($string){
  	$string = str_replace('&','&amp;',$string);
  	$string = str_replace('>','&gt;',$string);
  	$string = str_replace('<','&lt;',$string);
  	$string = str_replace('"','&quot;',$string);
  	return $string;
		//amp, lt, gt, apos, quot
    //return htmlspecialchars( $string, ENT_QUOTES , Oxygen::GetCharset() );
	}  
  public function Export(){
    if (is_null($this->value))
      return '';
    if ( is_string($this->value) )
      return self::escape($this->value);
    if ( $this->value instanceof Action)
      return self::escape( $this->value->GetHref() );
    if ( is_bool($this->value) )
      return $this->value ? 'true' : 'false';
    if ( is_int($this->value) )
      return sprintf('%d',$this->value);
    if ( is_float($this->value) )
      return sprintf('%F',$this->value);
    if ( $this->value instanceof ID )
      return $this->value->AsHex();
    if ( $this->value instanceof ImmutableTimeSpan )
      throw new Exception('Conversion from ImmutableTimeSpan to Html is not supported yet');
    if ( $this->value instanceof ImmutableDateTime )
      return strftime( '%a, %d %b %Y, %H:%M:%S' , $this->value->AsInt() );
    if ( $this->value instanceof DateTime )
      return strftime( '%a, %d %b %Y, %H:%M:%S' , $this->value->getTimestamp() );
    return self::escape( strval($this->value) );
  } 
  
  

}


  
?>
